<?php
namespace app\lib\resolution;
class Whosecard
{
    protected $token = '15f757413ee9118352062e4b6b80a9e55bded25dc600294df4ed873c';

    public function getDetail($short_url)
    {
        $apiUrl = "https://api.whosecard.com/api/xiaohongshu/note/detail?key=".$this->token.'&short_url='.$short_url;

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_URL, $apiUrl);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }

    public function getDetailByNoteId($note_id)
    {
        $apiUrl = "https://api.whosecard.com/api/xiaohongshu/note/detail?key=".$this->token.'&note_id='.$note_id;

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_URL, $apiUrl);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
}
